<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.w3.org/1999/xhtml">
<head>
    <th:block th:include="include :: header('注册')"/>
    <style>
        html{
            height: 100%;
        }
        body{
            height: 100%;
            background-color: #ede7e4;
            background-image: image('static/images/backColor.png');
        }
        .layui-form {
            padding: 15% 30% 15%;
        }
        .layui-btn {
            width: 100%;
        }
        .layui-input-block {
            margin-left: 28%;
        }
        .fr{
            margin-left: 78%;
        }
    </style>
</head>
<body>
<div style="height: 100%">
    <h1 style="text-align: center;margin-top: 5%">酒店管理系统注册</h1>
    <form class="layui-form" id="form"  action="#" >
        <div class="layui-form-item">
            <label class="layui-form-label">用户名</label>
            <div class="layui-input-block">
                <input type="text" name="username"  required lay-verify="required" placeholder="请输入用户名" autocomplete="off"
                       class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">密码</label>
            <div class="layui-input-block">
                <input type="password" name="password" required lay-verify="required" placeholder="请输入姓名" autocomplete="off"
                       class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <div class="layui-input-block">
                <button class="layui-btn" style="width: 80%" type="button" onclick="register()">注册</button>
            </div>
        </div>
        <p><a href="/admin/toLogin" class="fl">登录</a></p>
    </form>

</div>
<th:block th:include="include :: footer"/>
<script>
    function register(){
        $.post(ctxPath+'/admin/register',$("form").serialize(),function (res) {
            layui.use('layer', function(){
                var layer = layui.layer;
                layer.msg(res.msg);
            });
            if(res.code === 200){
                window.location.href = ctxPath+'/admin/toLogin'
            }
        });
    }
    layui.use('form', function () {
        var form = layui.form;
    });
</script>
</body>
</html>
